package pl.oczadly.jabberclient.addcontact.presenter;

import javax.swing.JOptionPane;

import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.XMPPException;

import pl.oczadly.jabberclient.connection.ConnectionHolder;
import pl.oczadly.jabberclient.utils.Utils;

public class AddContactPresenter implements IAddContactPresenter {

	private String id;
	private String name;
	
	public AddContactPresenter( String id, String name ) {
		this.id = id;
		this.name = name;
	}
	
	public void addContact() {
		Utils.setContactID( id );
		Utils.setContactName( name );
		
		Roster roster = ConnectionHolder.getRoster();
		try {
			roster.createEntry( Utils.getContactID(), Utils.getContactName(), null );
		} catch( XMPPException e1 ) {
			JOptionPane.showMessageDialog( null, e1.getMessage() );
		}
	}

}
